package org.heima.baselistdemo.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.heima.baselistdemo.Global;
import org.heima.baselistdemo.R;
import org.heima.baselistdemo.base.BaseListAdapter;
import org.heima.baselistdemo.bean2.GeneralNewsBean;

import java.util.List;

/**
 * Created by Shinelon on 2017/1/15.
 */

public class NewsListAdapter extends BaseListAdapter<List<GeneralNewsBean.NewsBean>> {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(Global.mContext).inflate(R.layout.item_news,parent,false);
        NewsHolder holder = new NewsHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        GeneralNewsBean.NewsBean data = (GeneralNewsBean.NewsBean) mList.get(position);
        ((NewsHolder)holder).tv.setText(data.getTitle());
    }

    class NewsHolder extends RecyclerView.ViewHolder{
        public TextView tv;
        public NewsHolder(View itemView) {
            super(itemView);
            tv = (TextView) itemView.findViewById(R.id.tv_name);
        }
    }
}
